Skip to content

Avoid rebuilding buffered queries - #2

Merged
Wedrix merged 1 commit into
mainfrom
agent/avoid-rebuilding-buffered-queries
Jul 23, 2026
Merged

Avoid rebuilding buffered queries#2
Wedrix merged 1 commit into
mainfrom
agent/avoid-rebuilding-buffered-queries

Conversation

@Wedrix

@Wedrix Wedrix commented Jul 23, 2026

Copy link
Copy Markdown
Owner

This pull request refactors the query execution logic in QueryResult to improve efficiency when dealing with buffered results, especially for nested collections. The main enhancement ensures that if a batch result is already available in the buffer, the query builder is not unnecessarily reconstructed. Additionally, a new test is added to verify this behavior.

Query execution optimization

  • Refactored QueryResult::__construct to check for an existing batch result in the buffer before rebuilding the query builder, preventing redundant query construction and improving performance for nested collection queries. [1] [2]
  • Updated the logic for retrieving the parent alias in nested queries to use an existing queryBuilder if available, or create a new one only when necessary.

Testing

  • Added tests/QueryResultTest.php with a test case to confirm that when a buffered nested result exists, the query builder is not rebuilt, ensuring the optimization works as intended.

@Wedrix Wedrix self-assigned this Jul 23, 2026
@Wedrix
Wedrix merged commit 37033a0 into main Jul 23, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant